$(document).ready(function() {
    $('input').each(function() {
        $(this).val('')
    });
    $('textarea').each(function() {
        $(this).val('')
    });
    window.scrollTo(0, 0);
    pageInit();
    queryStoreClassFunc();
    // provinceList();
});

//页面初始化
function pageInit() {
    $('#coverImgBox').hide();
    $('#albumWrap').hide();
    // $('#bannerImgBox').hide()
}

//商品分类
function getQueryString(key) {
    var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
    var result = window.location.search.substr(1).match(reg);
    return result
        ? decodeURIComponent(result[2])
        : null;
}
console.log(getQueryString('id'));

var storeClassVal;
var storeClassBool = false;
function queryStoreClassFunc() {
    var url = serverURL + '/store/queryStoreBindClass';
    data = {
        // 'storeId': 1
    };
    var cbk = function(res) {
        console.log(res);
        var data = res.data;
        var html = '';
        $('#classSelBox').empty();
        html += '<ul class="list-group" style="margin-bottom:0">'
        for (i in data) {
            html += '<li class="list-group-item" data-clsId="' + data[i].id1 + '-' + data[i].id2 + '-' + data[i].id3 + '"><input type="radio" name="iCheck">&nbsp;&nbsp;' + data[i].class1 + '&nbsp;&nbsp;>>&nbsp;&nbsp;' + data[i].class2 + '&nbsp;&nbsp;>>&nbsp;&nbsp;' + data[i].class3 + '</li>'
        }
        html += '</ul>';

        $('#classSelBox').append(html);
        $('#classSelBox input').iCheck({checkboxClass: 'icheckbox_flat-red', radioClass: 'iradio_flat-red'});
        $('#classSelBox input').on('ifChecked', function(event) {
            // console.log($(this).parents('.list-group-item').attr('data-clsId'));
            storeClassVal = $(this).parents('.list-group-item').attr('data-clsId');
            storeClassBool = true;
        });
        if (getQueryString('id')) {
            if (res.code == 200) {
                queryDetailFunc();
                // storeClassBool = true;
            }
        }
    }
    ajax(url, data, cbk, 'post', 'json');

}

//商品名称
var commodityNameBool = false;
if ($('#commodityName').val() != '' || commodityNameBool != false) {
    commodityNameBool = true;
}
$('#commodityName').on('input porpertychange change', function() {
    var str = $(this).val();
    if ((str.length > 0 && str.length < 3) || str.length > 50) {
        commodityNameBool = false;
        $('#commodityNameBox').css('color', 'red')
    } else {
        commodityNameBool = true
        $('#commodityNameBox').css('color', '')
    }
    console.log(commodityNameBool);
    // var res = ^.{3,6}$;
    // if (!res.test(str)) {
    //     commodityNameBool = false;
    // }else{
    //     commodityNameBool = true;
    // }
    // console.log(commodityNameBool);
    // if (str.length == 1) {
    //     obj.val(val.replace(/[^0-9]/g, ''));
    // } else {
    //     obj.val(val.replace(/\D/g, ''));
    // }
})

//商品卖点
var commodityCharacteristicsBool = false;
if ($('#commodityCharacteristics').val() != '' || commodityCharacteristicsBool != false) {
    commodityCharacteristicsBool = true;
}
$('#commodityCharacteristics').on('input porpertychange change', function() {
    var str = $(this).val();
    if (str.length > 140) {
        commodityCharacteristicsBool = false;
        $('#commodityCharacteristicsBox').css('color', 'red')
    } else {
        commodityCharacteristicsBool = true
        $('#commodityCharacteristicsBox').css('color', '')
    }
})
//折扣计算
var priceBool = false;
if ($('#price').val() != '' || priceBool != false) {
    priceBool = true;
}
var price = $('#price').val(); //商品价
// var marketValue = $('#marketValue').val() 市场价
$('#disCount').val((price / marketValue) * 100);
$('#price').on('input porpertychange change', function() {
    // var price = $(this).val(); 商品价
    // var marketValue = $('#marketValue').val() 市场价
    // $('#disCount').val((price / marketValue) * 100);
    if ($(this).val() > 9999999) {
        $(this).parents('.form-group').addClass('has-error')
    } else {
        $(this).parents('.form-group').removeClass('has-error');
        priceBool = true;
    }
    // var dC = $('#disCount').val()
    // if (dC.indexOf('.') != -1) {
    //      dC.substr(0,dC.indexOf('.'))
    //      console.log(dC.substr(dC.indexOf('.'),1));
    //     $('#disCount').val(dC.substr(0, dC.indexOf('.')))
    // }
})

//会员价格
var memberPriceBool = false;
if ($('#memberPrice').val() != '' || memberPriceBool != false) {
    memberPriceBool = true;
}
var memberPrice = $('#memberPrice').val(); //会员价
var marketValue = $('#marketValue').val() //市场价
$('#disCount').val((price / marketValue) * 100);
$('#memberPrice').on('input porpertychange change', function() {
    var price = $(this).val(); //商品价
    var marketValue = $('#marketValue').val() //市场价
    $('#disCount').val((price / marketValue) * 100);
    if ($(this).val() > 9999999) {
        $(this).parents('.form-group').addClass('has-error')
    } else {
        $(this).parents('.form-group').removeClass('has-error');
        memberPriceBool = true;
    }
    var dC = $('#disCount').val()
    if (dC.indexOf('.') != -1) {
        // dC.substr(0,dC.indexOf('.'))
        // console.log(dC.substr(dC.indexOf('.'),1));
        $('#disCount').val(dC.substr(0, dC.indexOf('.')))
    }
})

var marketValueBool = false;
if ($('#marketValue').val() != '' || marketValueBool != false) {
    marketValueBool = true;
}
$('#marketValue').on('input porpertychange change', function() {
    var price = $('#memberPrice').val();
    var marketValue = $(this).val()
    $('#disCount').val((price / marketValue) * 100);
    if ($(this).val() > 9999999) {
        $(this).parents('.form-group').addClass('has-error')
    } else {
        $(this).parents('.form-group').removeClass('has-error')
        marketValueBool = true;
    }
    var dC = $('#disCount').val()
    if (dC.indexOf('.') != -1) {
        // dC.substr(0,dC.indexOf('.'))
        // console.log(dC.substr(dC.indexOf('.'),1));
        $('#disCount').val(dC.substr(0, dC.indexOf('.')))
    }
})

var commodityStockBool = false;
if ($('#commodityStock').val() != '' || commodityStockBool != false) {
    commodityStockBool = true;
}
$('#commodityStock').on('input porpertychange change', function() {
    var commodityStock = $(this).val();
    if (commodityStock > 999999999) {
        $(this).parents('.form-group').addClass('has-error')
    } else {
        $(this).parents('.form-group').removeClass('has-error')
        commodityStockBool = true;
    }
});

$('#earlyWarningVal').on('input porpertychange change', function() {
    var earlyWarningVal = $(this).val();
    if (earlyWarningVal > 255) {
        $(this).parents('.form-group').addClass('has-error')
    } else {
        $(this).parents('.form-group').removeClass('has-error')
    }
});
//
$('.numInput').each(function() {
    $(this).on('input porpertychange change', function() {
        inputControl(this);
    });
})

//输入控制(只输入数字)
function inputControl(obj) {
    var obj = $(obj)
    var val = obj.val();
    if (val.length == 1) {
        obj.val(val.replace(/[^0-9]/g, ''));
    } else {
        obj.val(val.replace(/\D/g, ''));
    }
    return;
};

//输入控制（价格）
$('.priceInput').each(function() {
    $(this).on('input porpertychange change', function() {
        priceControl(this);
    });
})

function priceControl(obj) {
    var obj = $(obj)
    var money = obj.val();
    var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
    if (!reg.test(money) && money != '' || money > 9999999) {
        obj.parent().addClass('has-error')
    } else {
        obj.parent().removeClass('has-error')
    }
}

//输入控制（货号）
$('#businessItem').on('input porpertychange change', function() {
    var reg = /^[\u4e00-\u9fa5._\/a-zA-Z0-9]+$/;
    var str = $(this).val();
    if (!reg.test(str)) {
        $(this).parent().addClass('has-error')
    } else {
        $(this).parent().removeClass('has-error')
    }
})

//运费选项
$('input[name="freightRadios"]').change(function() {
    console.log($(this).val());
    var checkedVal = $(this).val();
    if (checkedVal == '1') {
        $('#fixedFreight').removeClass('invisible')
    } else {
        $('#fixedFreight').addClass('invisible')
    }
    if (checkedVal == '2') {
        $('#customFreight').removeClass('invisible')
    } else {
        $('#customFreight').addClass('invisible')
    }
})

var freightRadiosBool = false;
$('#fixedFreight input').on('input porpertychange change', function() {
    if ($(this).parent().hasClass('has-error')) {
        freightRadiosBool = false;
    } else {
        freightRadiosBool = true;
    }
})

//上架时间
$('input[name="releaseRadios"]').change(function() {
    var checkedVal = $(this).val();
    if (checkedVal === '2') {
        $("#timedRelease").datetimepicker({
            format: 'yyyy-mm-dd hh:ii:ss',
            autoclose: true,
            todayBtn: true,
            todayHighlight: true,
            showMeridian: true,
            showSecond: true,
            pickerPosition: "bottom-left",
            language: 'zh-CN', //中文，需要引用zh-CN.js包
            startView: 2, //月视图
            minView: 0, //日期时间选择器所能够提供的最精确的时间选择视图
            maxView: 2,
            minuteStep: 2
        })
    }
})

//商品描述
var E = window.wangEditor;
var editor = new E('#editor');
editor.customConfig.zIndex = 100;
editor.customConfig.uploadImgTimeout = 1000 * 60 * 60;
editor.customConfig.uploadImgMaxSize = 1024 * 1024 * 1024;
editor.customConfig.uploadImgServer = serverURL + "/goods/ossUpload";
editor.customConfig.uploadImgParams = {
    imgPath: 'goods' // 属性值会自动进行 encode ，此处无需 encode
};
editor.create();
$('.w-e-text-container').css('height', '400px')
$('.w-e-text img').css('width', '400px')

//商品图片上传
var imgStr = '';
var imgNames = [];
$('#addBanner').click(function() {
    if ($('.bannerBox').find("li").length < 5) {
        var html = '<li class="row"><form enctype="multipart/form-data" class="imgForm col-sm-6">' + '<input type="file" name="file" onchange="imgup(this,$(this).parent())" placeholder="图片尺寸：640*240" class="input04">' + '<input type="hidden" name="imgPath" value="goods">' + '</form>' + '<div class="imgsBox col-sm-2" style="margin:0 auto"></div>'
        // + '<div class="col-sm-2" style="margin:0 auto">'
        // + '<input type="text" class="form-control articleId" data-id="" value="" placeholder="文章编号">' + '</div>'
        + '<div class="col-sm-2" style="margin:0 auto">' + '<button type="button" class="btn btn-primary btn-danger delBanner">删除</button>' + '</div>' + '</li>'

        $('.bannerBox ul').append(html);
        $('.input04').filestyle({htmlIcon: '<span class="oi oi-folder"></span> ', text: '预览', btnClass: 'btn-primary'});
    } else {
        layer.msg('最多可上传5张banner')
    }
})

$(document).on('click', '.delBanner', function() {
    var _this = $(this)
    layer.confirm('确定要删除吗？', {
        btn: ['确定', '取消'] //按钮
    }, function() {
        _this.parent().parent().remove();
        layer.closeAll('dialog');
    }, function() {});
})

$(document).on('click', '.bannerImg', function() {
    console.log($(this).attr('src'));
    layer.open({
        type: 1,
        title: false,
        closeBtn: 0,
        area: '516px',
        skin: 'layui-layer-nobg', //没有背景色
        shadeClose: true,
        content: '<img class="img-thumbnail" src="' + $(this).attr('src') + '" />'
    });
})

//图片上传
function imgup(upImg, ADD) {
    var datas = new FormData(ADD[0]);
    var size = upImg.files[0].size; //得到图片的大小
    var trueSize = Math.ceil(size / 1024); //把字节转换成kb
    if (trueSize > 2048) {
        alert("请上传小于2M的图片")
        return false;
    }
    var fileImg = upImg.files[0].name; //图片名
    var extStart = fileImg.lastIndexOf(".");
    var ext = fileImg.substring(extStart, fileImg.length).toUpperCase();
    if (ext != ".BMP" && ext != ".PNG" && ext != ".GIF" && ext != ".JPG" && ext != ".JPEG") {
        alert("图片类型必须是.gif,jpeg,jpg,png中的一种")
        return false;
    };
    console.log(datas)
    $.ajax({
        url: serverURL + '/goods/getOssUpload',
        type: "post",
        dataType: "json",
        cache: false,
        contentType: false,
        processData: false,
        data: datas,
        xhrFields: {
            withCredentials: true
        },
        success: function(data) {
            if (data.code == 200) {
                // 	var srcs = getObjectURL(upImg.files[0]);
                // $(upImg).val(data.data)
                var src = data.data.apicCover;
                console.log(data);
                $(upImg).parent().next('.imgsBox').html('<img class="img-thumbnail bannerImg" src="http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com/' + src + '" alt="" width="35"><input type="hidden" name="" value="' + src + '" class="imgName">')
            }
        }
    });
    return false
}

//商品详情插入图片
var boolOpenAlbum = false;
$('#btnOpenAlbum').click(function() {
    boolOpenAlbum = !boolOpenAlbum;
    // $('#albumWrap').show()
    if (boolOpenAlbum == false) {
        $(this).text('插入相册图片')
        $('#albumWrap').hide()
    } else {
        $(this).text('关闭相册')
        $('#albumWrap').show();
        getAlbumFunc();
    }
});

function getAlbumFunc() {
    var albumUrl = serverURL + '/goods/queryAlbumClass';
    data = {
        'page': page,
        'pageSize': pagesize,
        // 'storeId': 1
    };
    var cbk = function(res) {
        var data = res.data;
        $('.panel-heading span').text(data[0].aclassName)
        $('#albumSel').empty();
        for (i in data) {
            $('#albumSel').append('<option value="' + data[i].aclassId + '">' + data[i].aclassName + '</option>')
        }
        imgListInit()
    }
    ajax(albumUrl, data, cbk, 'post', 'json')
};

$('#albumSel').change(function() {
    $('.panel-heading span').text($(this).find('option:selected').text())
    // console.log($(this).val());
    aclassIdVal = $(this).val();
    imgListInit();
});

var page = 1;
var pagesize = 6;
var aclassIdVal = 1;
var pageUrls = serverURL + '/goods/queryAlbumPic';
//http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com
function imgListInit() {
    data = {
        'page': page,
        'pageSize': pagesize,
        'aclassId': aclassIdVal
    };
    data.page = 1;
    ajax(pageUrls, data, pageNumList, 'post', 'json')
}

function OpendList(res) {
    // console.log(res);
    $('#imgListBox').empty();
    var data = res.data.list;
    var html = '';
    for (i in data) {
        var imgStr = data[i].apicCover;
        var imgStartPos = imgStr.indexOf('/');
        var imgTit = imgStr.substr(imgStartPos + 1);
        html += '<li class="col-sm-6 col-md-2">' + '<a class="thumbnail" href="javascript:;" data-caption="' + imgTit + '" >' + '<img alt="' + imgTit + '" src="' + 'http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com//' + data[i].apicCover + '"></a>' +
        // '<div class="checkbox"><label><input class="comCkeckbox" type="checkbox" data-id="' + data[i].apicId + '" class="choose" value="0" aria-label="...">&nbsp;&nbsp;选择</label></div>' +
        '</li>'
    }
    $('#imgListBox').append(html);
    $('.gallery a').height($('.gallery a').width());
    $('.gallery a').click(function() {
        console.log($(this).children('img').attr('src'));
        editor.txt.append('<img width="600" src="' + $(this).children('img').attr('src') + '" />')
    })

}

$(window).resize(function() {
    $('.gallery a').height($('.gallery a').width());
    $('#imgWrap span').height($('#imgWrap span').width());
});

//城市列表
// provinceList()
// function provinceList() {
//     var cityUrl = 'http://www1.wuyoutianxia.com/zwy/app/getWmArea';
//     data = {
//         'areaParentId': ''
//     };
//     ajax(cityUrl, data, provinceShow, 'post', 'json')
// }
//
// function provinceShow(res) {
//     console.log(res);
//     var data = res.data;
//     $('#province');
//     $('#province').empty();
//     $('#province').append('<option value="0">请选择省/市</option>')
//     for (i in data) {
//         $('#province').append('<option value="' + data[i].areaId + '">' + data[i].areaName + '</option>')
//     }
// }
//
// $('#province').change(function() {
//     ctId = $('#province option:selected').val();
//     cityList();
// })
// function cityList() {
//     var cityUrl = 'http://www1.wuyoutianxia.com/zwy/app/getWmArea';
//     data = {
//         'areaParentId': ctId
//     };
//     ajax(cityUrl, data, cityShow, 'post', 'json')
// }
//
// function cityShow(res) {
//     console.log(res);
//     if (res.code == '200') {
//         $('#city').removeClass('hidden')
//     }
//     var data = res.data;
//     $('#city').empty();
//     for (i in data) {
//         $('#city').append('<option value="' + data[i].areaId + '">' + data[i].areaName + '</option>')
//     }
// }

//提交发布商品
$('#btnProRelease').click(function() {
    $('.imgName').each(function() {
        imgNames.push($(this).val())
    });

    console.log(imgNames);
    console.log(String(imgNames));
    // console.log($('.iradio_flat-red').hasClass('ckecked'));
    if (storeClassBool == false) {
        layer.msg('请选择商品分类')
        return;
    }

    if ($('#commodityName').val() == '' || commodityNameBool == false) {
        layer.msg('请正确填写商品名称')
        return;
    }

    if (priceBool == false || $('#price').val() == '') {
        layer.msg('请正确填写商品价格')
        return
    }

    if (parseInt($('#memberPrice').val()) > parseInt($('#price').val())) {
        layer.msg('请正确填写会员价格')
        return
    }
    if (memberPriceBool == false || $('#memberPrice').val() == '') {
        layer.msg('请正确填写会员价格')
        return
    }

    if (marketValueBool == false || $('#marketValue').val() == '') {
        layer.msg('请正确填写市场价')
        return
    }
    if (commodityStockBool == false || $('#commodityStock').val() == '') {
        layer.msg('请正确填写商品库存')
        return
    }

    if (imgNames.length == 0) {
        layer.msg('请上传商品主图')
        return
    }
    if ($('#fixedFreight input').val() == '' || freightRadiosBool == false) {
        layer.msg('请正确填写运费');
        return;
    }

    var proUrl = serverURL + '/goods/saveGoods';
    var upUrl = serverURL + '/goods/updateGoods';
    var storeClassId = storeClassVal.split('-');
    var isSpeVal;
    if (storeClassId[0] == 1000127) {
        isSpeVal = 1;
    } else {
        isSpeVal = 0;
    }
    data2 = {
        'goodsId': getQueryString('id'),
        'goodsName': $('#commodityName').val(),
        'goodsJingle': $('#commodityCharacteristics').val(),
        'goodsCommonid': goodsCommonidVal,
        'goodsSalenum': $('#salesVolume').val(),
        'gcId1': storeClassId[0],
        'gcId2': storeClassId[1],
        'gcId3': storeClassId[2],
        'isSpe': isSpeVal,
        'goodsPrice': $('#price').val(),
        'memberPrice': $('#memberPrice').val(),
        'goodsMarketprice': $('#marketValue').val(),
        'goodsStorage': $('#commodityStock').val(),
        'goodsStorageAlarm': $('#earlyWarningVal').val(),
        'goodsSerial': $('#businessItem').val(),
        'goodsImage': imgNames[0],
        'goodsImageList': String(imgNames),
        'goodsFreight': $('#fixedFreight input').val(),
        'goodsBody': editor.txt.html()
    }

    data = {
        'goodsName': $('#commodityName').val(),
        'goodsJingle': $('#commodityCharacteristics').val(),
        // 'storeId': 1,
        'gcId1': storeClassId[0],
        'gcId2': storeClassId[1],
        'gcId3': storeClassId[2],
        'isSpe': isSpeVal,
        // 'brandId':,//品牌ID
        'goodsPrice': $('#price').val(),
        'memberPrice': $('#memberPrice').val(),
        'goodsMarketprice': $('#marketValue').val(),
        'goodsStorage': $('#commodityStock').val(),
        'goodsStorageAlarm': $('#earlyWarningVal').val(),
        'goodsSerial': $('#businessItem').val(),
        'goodsImage': imgNames[0],
        'goodsImageList': String(imgNames),
        'goodsSalenum': $('#salesVolume').val(),
        //  'goodsPromotionType': 0, 促销类型：0无促销1团购2限时折扣
        //  'colorId': 1, 颜色规格id
        //  'transportId': 1, 运费模板id
        'goodsFreight': $('#fixedFreight input').val(),
        //  'goodsVat': $('input[name="goodsVat"]').val(), 是否开具增值税发票：1是 0否 默认为0
        //  'goodsCommend': $('input[name="goodsCommend"]').val(), 商品推荐: 1:是 0否 默认为0
        // 'evaluationCount':'',//评价数
        // 'isFcode': 0, 是否为F码商品
        // 'isAppoint': $('input[name="isAppoint"]').val(), 是否预约
        // 'isPresell': 0, 是否为预售商品：1是0否
        // 'haveGift': 0, 是否拥有赠品：1是0否
        // 'isOwnShop': 0, 是否为平台自营：1是0否
        // 'storeName': 0, 商铺名称
        'goodsBody': editor.txt.html(),
        // 'areaId1': $('#province').val(),
        // 'areaId2': $('#city').val()
    };
    var cbk = function(res) {
        $('#btnProRelease').attr('disabled', true);
        $('#btnProRelease').text('提交中');
        if (res.code == 200) {
            $('#btnProRelease').attr('disabled', false);
            $('#btnProRelease').text('发布商品');
            setTimeout(function() {
                window.location.reload()
            }, 2000);
        }
    }

    if (getQueryString('id')) {
        ajax(upUrl, data2, cbk, 'post', 'json')
    } else {
        ajax(proUrl, data, cbk, 'post', 'json')
    }
    // ajax(proUrl, data, cbk, 'post', 'json',)
})

//编辑页面回显
var goodsCommonidVal;
function queryDetailFunc() {
    if (getQueryString('id')) {
        var url = serverURL + '/goods/queryGoodsDetail';
        data = {
            'goodsId': getQueryString('id')
        }
        var cbk = function(res) {
            console.log(res);
            if (res.code == 200) {
                var data = res.data;
                var goodsClassStr = data.gId1 + '-' + data.gId2 + '-' + data.gId3;
                storeClassVal = data.gId1 + '-' + data.gId2 + '-' + data.gId3;
                var listItem = $('.list-group-item');
                for (i in listItem) {
                    if (listItem.eq(i).attr('data-clsId') == goodsClassStr) {
                        listItem.eq(i).children('.iradio_flat-red').addClass('checked');
                        storeClassBool = true;
                    }
                }
                console.log(storeClassBool);
                $('#commodityName').val(data.goodsName);
                commodityNameBool = true;
                $('#commodityCharacteristics').val(data.goodsJingle);
                commodityStockBool = true;
                $('#price').val(data.goodsPrice); //商品价格
                priceBool = true;
                $('#memberPrice').val(data.memberPrice);
                memberPriceBool = true;
                $('#marketValue').val(data.goodsMarketprice); //市场价
                marketValueBool = true;
                $('#commodityStock').val(data.goodsStorage); //库存
                $('#earlyWarningVal').val(data.goodsStorageAlarm); //库存报警值
                $('#businessItem').val(data.goodsSerial); //商家货号
                // 'goodsImage': imgStr, 商品主图
                // 'goodsPromotionType': 0, 促销类型：0无促销1团购2限时折扣
                //  'colorId': 1, 颜色规格id
                //  'transportId': 1, 运费模板id
                $('#salesVolume').val(data.goodsSalenum); //销量
                $('#fixedFreight input').val(data.goodsFreight); //运费0为免运费
                freightRadiosBool = true;
                // $('input[name="goodsVat"][value="' + data.goodsVat + '"]').attr('checked', true), 是否开具增值税发票：1是 0否 默认为0
                // $('input[name="goodsCommend"][value="' + data.goodsCommend + '"]').attr('checked', true), 商品推荐: 1:是 0否 默认为0
                //  'evaluationCount':'',//评价数
                // 'isFcode': 0, 是否为F码商品
                $('input[name="isAppoint"][value="' + data.isAppoint + '"]').attr('checked', true), //是否预约
                // 'isPresell': 0, 是否为预售商品：1是0否
                // 'haveGift': 0, 是否拥有赠品：1是0否
                // 'isOwnShop': 0, 是否为平台自营：1是0否
                // 'storeName': 0, 商铺名称
                // 'goodsBody': editor.txt.html(), 商品详情信息
                editor.txt.html(data.goodsBody); //商品详情信息
                if (data.goodsImage != '') {
                    $('#coverImgBox').show()
                    $('#imgCover').attr('src', 'http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com/' + data.goodsImage)
                }
                goodsCommonidVal = data.goodsCommonid;
                // $('#bannerImgBox').show();
                for (i in data.goodsImageList) {
                    var html = '<li class="row"><form enctype="multipart/form-data" class="imgForm col-sm-6">' + '<input type="file" name="file" onchange="imgup(this,$(this).parent())" placeholder="图片尺寸：640*240" class="input04" value="' + data.goodsImageList[i].goodsBannerImage + '">' + '<input type="hidden" name="imgPath" value="goods">' + '</form>' + '<div class="imgsBox col-sm-2" style="margin:0 auto"><img class="img-thumbnail bannerImg" src="http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com/' + data.goodsImageList[i].goodsBannerImage + '" alt="" width="35"><input type="hidden" name="" value="' + data.goodsImageList[i].goodsBannerImage + '" class="imgName"></div>' + '<div class="col-sm-2" style="margin:0 auto">' + '<button type="button" class="btn btn-primary btn-danger delBanner">删除</button>' + '</div>' + '</li>';
                    // $('.imgsBox').html('<img class="img-thumbnail" src="http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com/' + data.goodsImageList[i].goodsImage + '" alt="" width="35"><input type="hidden" name="" value="' + data.goodsImageList[i].goodsImage + '" class="imgName">')
                    $('.bannerBox ul').append(html)
                }
                $('.input04').filestyle({htmlIcon: '<span class="oi oi-folder"></span> ', text: '预览', btnClass: 'btn-primary'});
            }
            // 'areaId1': $('#province').val(),
            // 'areaId2': $('#city').val()
        }
        ajax(url, data, cbk, 'post', 'json')
    }
}
